package mest.controller.system;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;

import mest.entity.User;
import mest.service.system.UserService;
import mest.util.ResultObj;

/**
 *@Title UserController.java
 *@description TODO
 *@time 2019年12月15日 下午8:31:09
 *@author Twinson Wong
 **/
@RestController
@CrossOrigin
@RequestMapping(value = "/user")
public class UserController {


	@Resource
	UserService userService;
	
	@RequestMapping(value="/getUserList")
	public ResultObj getUserList(@RequestBody JSONObject jsonObject, HttpServletRequest request){
		try {
			Map<String, Object> map = jsonObject.toJavaObject(Map.class);
			HttpSession session = request.getSession();
			User user = (User)session.getAttribute("user");
			List<User> userList = userService.getUserList(user);
			return ResultObj.createSuccessMsg(ResultObj.LOGIN_SUCCESS);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			return ResultObj.createErrorMsg(ResultObj.ERROR2);
		}
	}
}
